<template>
<el-container>
  <el-header>
    <el-image :src="require('@/assets/images/sdu_logo.png')" style="width: 5vh;margin-top:10px;float:left"></el-image>
    <span style="font-size: 1.5vw;line-height: 60px;float:left;margin-left: 15px;margin-top:5px;font-family: cursive;">氢能经济性分析和规划设计系统</span>
    <!-- <span style="font-size: 16px;line-height: 60px;float:left;margin-left: 350px;margin-top:5px;">当前项目:
      <el-select v-model="projectName" placeholder="所有楼宇" @change="findProjectId(projectName)">
      <el-option
        v-for="item in projectNames"
        :key="item.id"
        :label="item.name"
        :value="item.id">
      </el-option>
    </el-select>
    </span> -->
    
    <div style="width: 25vh; height: 100%;float: right;display: inline">
      <div style="display: inline;font-size: 1.7vh; margin-top: 0vh;line-height: 7vh;">欢迎您，<span id="userNameId"></span></div>
      <el-image @click="logout()" :src="require('@/assets/images/logout.png')" style="display: inline-block;position: absolute;margin-left: 1vh;margin-top: 2.1vh;cursor: pointer;"></el-image>
    </div>

    
  </el-header>
  <el-container style="overflow: hidden;">
    <el-aside width="220px">

      <router-link :to="{path:'/'}">
        <el-button :class="[ selectItem =='mainPage' ? 'button-item-select':'button-normal' ]"
                   @click="clickProject('mainPage')" style="margin-top:0px" >
          <el-image :src="require('@/assets/u12.svg')" class="button-icon" ></el-image>
          <span    class="button-text" >首页</span>
        </el-button>
      </router-link>

      <router-link :to="{path:'/projectManagement'}">
        <el-button :class="[ selectItem =='projectManagement' ? 'button-item-select':'button-normal' ]"
                   @click="clickProject('projectManagement')" style="margin-top:0px" >
          <el-image :src="require('@/assets/u12.svg')" class="button-icon" ></el-image>
          <span    class="button-text" >项目管理</span>
        </el-button>
      </router-link>

      <router-link :to="{path:'/econmicProjectMaintenance'}">
        <el-button :class="[ selectItem =='econmicProjectMaintenance' ? 'button-item-select':'button-normal' ]"
                   @click="clickProject('econmicProjectMaintenance')" style="margin-top:0px" >
          <el-image :src="require('@/assets/economicAnalysis.svg')" class="button-icon" ></el-image>
          <span    class="button-text" >经济性分析</span>
        </el-button>
      </router-link>
      
      <router-link :to="{path:'/designProjectMaintenance'}">
        <el-button :class="[ selectItem =='designProjectMaintenance' ? 'button-item-select':'button-normal' ]"
                   @click="clickProject('designProjectMaintenance')" style="margin-top:0px" >
          <el-image :src="require('@/assets/u15.png')" class="button-icon" ></el-image>
          <span    class="button-text" >规划设计</span>
        </el-button>
      </router-link>

      <!-- <router-link :to="{path:'/loadSimulation',query: { project_id: this.project_id }}">
      <el-button :class="[ selectItem =='loadSimulation' ? 'button-item-select':'button-normal' ]"
                 @click="clickProject('loadSimulation')" style="margin-top:3px">
        <el-image :src="require('@/assets/u13.png')" class="button-icon" ></el-image>
        <span   class="button-text" >建模仿真</span>
      </el-button>
      </router-link>
      <router-link :to="{path:'/planProgram'}">
        <el-button :class="[ selectItem =='planProgram' ? 'button-item-select':'button-normal' ]"
                   @click="clickProject('planProgram')" style="margin-top:3px">
          <el-image :src="require('@/assets/u15.png')" class="button-icon" ></el-image>
          <span   class="button-text" >方案规划</span>
        </el-button>
      </router-link>
      <router-link :to="{path:'/dispatch'}">
        <el-button :class="[ selectItem =='dispatch' ? 'button-item-select':'button-normal' ]"
                   @click="clickProject('dispatch')" style="margin-top:3px">
          <el-image :src="require('@/assets/u14.png')" class="button-icon" ></el-image>
          <span   class="button-text" >调度优化</span>
        </el-button>
      </router-link> -->

      <router-link :to="{path:'/basicDatabase'}">
      <el-button :class="[ selectItem =='basicDatabase' ? 'button-item-select':'button-normal' ]"
                 @click="clickProject('basicDatabase')" style="margin-top:0px">
        <el-image :src="require('@/assets/database.png')" class="button-icon" ></el-image>
        <span   class="button-text" >基础数据库</span>
      </el-button>
      </router-link>

      <router-link :to="{path:'/resourceBase'}">
      <el-button :class="[ selectItem =='resourceBase' ? 'button-item-select':'button-normal' ]"
                 @click="clickProject('resourceBase')" style="margin-top:0px">
        <el-image :src="require('@/assets/u16.png')" class="button-icon" ></el-image>
        <span   class="button-text" >设备库</span>
      </el-button>
      </router-link>

    </el-aside>
    <el-main>
      <router-view/>
    </el-main>
  </el-container>
</el-container>
</template>

<script>
export default {
  name: 'MainView',
  created(){
    this.findPro();
  },
  data() {
    return {
      selectItem: 'project',
      projectNames:[],
      projectName: "",
      project_id:this.$root.project_id
    }
  },
  mounted() {
    var username = sessionStorage.getItem("username");
    $("#userNameId").text(username);
  },
  methods: {
    logout : function(){
      sessionStorage.setItem("username","");
      sessionStorage.setItem("account", "");
      sessionStorage.setItem("token", 'false');
      this.$router.push({path: "/login"});
    },
    clickProject (id) {
      if (this.selectItem === id) {
        return
      }
      this.selectItem = id
    },
    //查所有项目id name
    findPro(){
      this.$http.post("/iepsapi/project/findPro").then((res) => {
        if(res.data.flag){
          this.projectNames = res.data.data;
        }
      });
    },
    findProjectId(projectName){
      this.$root.project_id=projectName;
    },
  }
}
</script>

<style>
.el-form-item__label {
    text-align: right;
    vertical-align: middle;
    float: left;
    font-size: 14px;
    color: #FFF !important;
    line-height: 40px;
    padding: 0 12px 0 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  .el-input__inner {
    background-color: #202b6180;
    background-image: none;
    border-radius: 4px;
    border: 1px solid #5c7bc5;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    color: #a3aec5;
    display: inline-block;
    font-size: inherit;
    height: 40px;
    line-height: 40px;
    outline: 0;
    padding: 0 15px;
    -webkit-transition: border-color .2s cubic-bezier(.645,.045,.355,1);
    transition: border-color .2s cubic-bezier(.645,.045,.355,1);
    width: 100%;
}

.el-input-group__append, .el-input-group__prepend {
    background-color: #305997;
    color: #ffffff;
    vertical-align: middle;
    display: table-cell;
    position: relative;
    border: 1px solid #506aa7;
    border-radius: 4px;
    padding: 0 20px;
    width: 1px;
    white-space: nowrap;
}
</style>

<style scoped>
.el-button:focus, .el-button:hover {
    color: #ffffff;
    /* border-color: #c6e2ff; */
    background-color: #008FE0;
}

.el-form-item__label {
    text-align: right;
    vertical-align: middle;
    float: left;
    font-size: 14px;
    color: #FFF !important;
    line-height: 40px;
    padding: 0 12px 0 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  
  .el-input__inner {
    background-color: #202b6180;
    background-image: none;
    border-radius: 4px;
    border: 1px solid #5c7bc5;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    color: #a3aec5;
    display: inline-block;
    font-size: inherit;
    height: 40px;
    line-height: 40px;
    outline: 0;
    padding: 0 15px;
    -webkit-transition: border-color .2s cubic-bezier(.645,.045,.355,1);
    transition: border-color .2s cubic-bezier(.645,.045,.355,1);
    width: 100%;
}

.el-input-group__append, .el-input-group__prepend {
    background-color: #305997;
    color: #ffffff;
    vertical-align: middle;
    display: table-cell;
    position: relative;
    border: 1px solid #506aa7;
    border-radius: 4px;
    padding: 0 20px;
    width: 1px;
    white-space: nowrap;
}

  .button-text{
    font-size: 12px;
    float:left;
    margin-left: 10px;
    margin-top:8px;
    margin-bottom: 10px;
  }
  .button-but{
    font-size: 15px;
    float:right;
    margin-left: 10px;
    margin-top:4px;
  }
  .button-icon{
    width: 22px;
    height: 22px;
    margin-left:10px;
    float:left
  }
  .button-normal{
    width: 198px;
    height: 98px;
    background: #162E5A;
    border-width: 1px;
    color:white;
    margin-left: 11px;
    font-weight: normal;
    border-color: #2F3D8A;
  }
  .button-item-select{
    width: 198px;
    height: 98px;
    background: #008FE0;
    border-width: 1px;
    color:white;
    margin-left: 11px;
    font-weight: bold;
    border-color: #2F3D8A;
  }

  .el-container{
    margin:0;
    padding:0;
    height:100%;
  }

  .el-header{
    background-color: #161E43;
    color: white;
    height: 67px !important;
    padding-left: 10px;
  }

  .el-aside {
    background-color: #161E43;
  }
  .el-main {
    /* background-color: #2d3d88; */
    background-image: url(../assets/images/systemBg.png);
    color: #333;
    text-align: center;
    height: 100%;
  }
  .add{
    font-size: 22px;
    float: left;
  }
</style>
